package de.tabuma.soapforms.soapproject.view;

import de.tabuma.lib.tabumaview;
import de.tabuma.soapforms.*;
import java.io.*;
import java.util.*;
import java.util.logging.*;
import javax.servlet.*;
import javax.servlet.http.*;

/**
 *
 * @author alefen
 */
public class view extends tabumaview {
    private static Logger log = Logger.getLogger(view.class.getName());
    public view(String servlet, Hashtable parameter) {
        super(servlet, parameter);
    }

    @Override
    public void processRequest(ServletContext context, HttpServletRequest request, HttpServletResponse response, PrintWriter out) {


        String soapProjects = "Soap Projects";
        out.println("<div class=\"contentHeader\">"+soapProjects+"</div>");

        out.println("<div class=\"contentContent\">");
        
        if(request.getAttribute(constants.soapProjectErrorMessage)!=null) {
            out.println("<div class=\"errormessage\">");
            out.println("<div class=\"errormessage1\">");
            out.println(request.getAttribute(constants.soapProjectErrorMessage));
            out.println("</div>");
            out.println("</div>");
        }
        if(request.getAttribute(constants.soapProjectSuccessMessage)!=null) {
            out.println("<div class=\"infomessage\">");
            out.println("<div class=\"infomessage1\">");
            out.println(request.getAttribute(constants.soapProjectSuccessMessage));
            out.println("</div>");
            out.println("</div>");
        }
        String output = "Request-Param:\n";
        Enumeration<String> enu = this.getParameter().keys();
        while(enu.hasMoreElements()) {
            String key = enu.nextElement();
            Object value = this.getParameter().get(key);
            output += key+"="+value+"\n";
        }
        output += "Attributes:\n";
        enu = request.getAttributeNames();
        while(enu.hasMoreElements()) {
            String key = enu.nextElement();
            Object value = request.getAttribute(key);
            output += key+"="+value+"\n";
        }
        log.warning(output);

        if(request.getAttribute(constants.addSoapProject)!=null) {
            create create = new create(this.getServlet(), this.getParameter());
            create.processRequest(context, request, response, out);
        }

        if(request.getAttribute(constants.addSoapProject1)!=null) {
            create1 create1 = new create1(this.getServlet(), this.getParameter());
            create1.processRequest(context, request, response, out);
        }

        if(request.getAttribute(constants.updateSoapProject)!=null) {
            update update = new update(this.getServlet(), this.getParameter());
            update.processRequest(context, request, response, out);
        }

        if(request.getAttribute(constants.removeSoapProject)!=null) {
            remove remove = new remove(this.getServlet(), this.getParameter());
            remove.processRequest(context, request, response, out);
        }

        if(request.getAttribute(constants.showCustomerList)!=null) {
            list list = new list(this.getServlet(), this.getParameter());
            list.processRequest(context, request, response, out);
        }
        
        out.println("</div>");
    }
}